<table width="100%" bgcolor="#b0c4da"><tr colspan="2"><td>Manual Pages</td></tr>
<tr><td><h3>mcs(1)</h3></td><td align="right">6 January 2001</td></tr></table>
<h2>NAME </h2><blockquote>
mcs, gmcs, smcs - Mono C# Compiler (1.0, 2.0, Moonlight)
</blockquote><h2>SYNOPSIS</h2><blockquote>
<b>mcs </b>
[option] [source-files]
</blockquote><h2>DESCRIPTION</h2><blockquote>
mcs is the Mono C# compiler, an implementation of the ECMA-334
language specification.  You can pass one or more options to drive the
compiler, and a set of source files.  Extra options or arguments can
be provided in a response file.  Response files are referenced by
prepending the @ symbol to the response file name.
<p>
The 
<i>mcs</i>
compiler is used to compile against the 1.x profile and implements
C# 1.0 and 2.0 with the exception of generics and nullable types.
</p><p>
The
<i>gmcs</i>
compiler is used to compile against the 2.0 profile and implements
the complete C# 2.0 specification including generics.
</p><p>
The
<i>smcs</i>
compiler is used to compile against the Silverlight/Moonlight profile.
This profile is designed to be used for creating Silverlight/Moonlight
applications that will run on a web browser.   The API exposed by this
profile is a small subset of the 2.0 API (even if it is commonly
referred as the 2.1 API, this API is a small subset of 2.0 with a few
extensions), in addition this profile by default runs with
-langversion:linq which turns on the C# 3.0 language by default.
</p><p>
The Mono C# compiler accepts the same command line options that the
Microsoft C# compiler does.  Those options can start with a slash or a
dash (/checked is the same as -checked).  Additionally some GNU-like
options are supported, those begin with "--".  All MCS-specific flags
which are not available in the Microsoft C# compiler are available
only with the GNU-style options.
</p><p>
C# source files must end with a ".cs" extension.  Compilation of C#
source code requires all the files that make up a library, module or
executable to be provided on the command line.  There is no support
for partial compilation.  To achieve the benefits of partial
compilation, you should compile programs into their own assemblies,
and later reference them with the "-r" flag.
</p><p>
The Mono C# compiler generates images (.exe files) that contain CIL
byte code that can be executed by any system that implements a Common
Language Infrastructure virtual machine such as the Microsoft .NET
runtime engine on Windows or the Mono runtime engine on Unix systems.
Executables are not bound to a specific CPU or operating system.
</p><p>
The Mono C# compiler by default only references three assemblies:
mscorlib.dll, System.dll and System.Xml.dll.   If you want to
reference extra libraries you must manually specify them using the
-pkg: command line option or the -r: command line option.
Alternatively if you want to get all of the System libraries, you can
use the -pkg:dotnet command line option.
</p><p>
</p></blockquote><h2>OPTIONS</h2><blockquote>
<dl><dt>
<i>--about</i></dt><dd>
Displays information about the Mono C# compiler
</dd><dt>
<i>--addmodule:MODULE1[,MODULE2]</i></dt><dd>
Includes the specified modules in the resulting assembly.  
</dd><dt>
<i>-checked, -checked+</i></dt><dd>
Sets the default compilation mode to `checked'.  This makes all
the math operations checked (the default is unchecked).
</dd><dt>
<i>-checked-</i></dt><dd>
Sets the default compilation mode to `unchecked'.  This makes all
the math operations unchecked (this is the default).
</dd><dt>
<i>-codepage:ID</i></dt><dd>
Specifies the code page used to process the input files from the
point it is specified on.  By default files will be processed in the
environment-dependent native code page.  The compiler will also automatically
detect Unicode files that have an embedded byte mark at the beginning.   
<p>
Other popular encodings are 28591 (Latin1), 1252 (iso-8859-1) and 65001 (UTF-8).
</p><p>
MCS supports a couple of shorthands: "utf8" can be used to specify utf-8 instead
of using the cryptic 65001 and "reset" restores the automatic handling of
code pages.  These shorthands are not available on the Microsoft compiler.
</p></dd><dt>
<i>-define:SYMLIST, -d:SYMLIST</i></dt><dd>
Defines the symbol listed by the semi-colon separated list SYMLIST
SYMBOL.  This can be tested in the source code by the pre-processor,
or can be used by methods that have been tagged with the Conditional
attribute. 
</dd><dt>
<i>-debug, -debug+, -g</i></dt><dd>
Generate debugging information.  To obtain stack traces with debugging
information, you need to invoke the mono runtime with the `--debug'
flag.  This debugging information is stored inside the assembly as a
resource.
</dd><dt>
<i>-debug-</i></dt><dd>
Do not generate debugging information.
</dd><dt>
<i>-delaysign+</i></dt><dd>
Only embed the strongname public key into the assembly. The actual 
signing must be done in a later stage using the SN tool. This is useful
to protect the private key during development. Note that delay signing
can only be done using a strongname key file (not a key container). The
option is equivalent to including [assembly: AssemblyDelaySign (true)] 
in your source code. Compiler option takes precedence over the 
attributes.
</dd><dt>
<i>-delaysign-</i></dt><dd>
Default. Strongname (sign) the assembly using the strong name key file
(or container). The option is equivalent to including [assembly: 
AssemblyDelaySign (false)] in your source code. Compiler option takes
precedence over the attributes.
</dd><dt>
<i>-doc:FILE</i></dt><dd>
Extracts the C#/XML documentation from the source code and stores in in
the given FILE.
</dd><dt>
<i>--expect-error X L</i></dt><dd>
The compiler will expect the code to generate an error 
named `X' in line `L'.  This is only used by the test suite.
</dd><dt>
<i>--fatal </i></dt><dd>
This is used for debugging the compiler.  This makes the error emission
generate an exception that can be caught by a debugger.
</dd><dt>
<i>-keyfile:KEYFILE</i></dt><dd>
Strongname (sign) the output assembly using the key pair present in 
the specified strong name key file (snk). A full key pair is required
by default (or when using delaysign-). A file containing only the
public key can be used with delaysign+. The option is equivalent to 
including [assembly: AssemblyKeyFile ("KEYFILE")] in your source code.
Compiler option takes precedence over the attributes.
</dd><dt>
<i>-keycontainer:CONTAINER</i></dt><dd>
Strongname (sign) the output assembly using the key pair present in 
the specified container. Note that delaysign+ is ignored when using 
key containers. The option is equivalent to including [assembly: 
AssemblyKeyName ("CONTAINER")] in your source code. Compiler option 
takes precedence over the attributes.
</dd><dt>
<i>-langversion:TEXT</i></dt><dd>
The option specifies the version of the language to use. The feature
set is different in each C# version. This switch can be used to force
the compiler to allow only a subset of the features.
The possible values are:
<blockquote>

<dl><dt>
<i>Default</i></dt><dd>
Instruct compiler to use the latest version. Equivalent is to omit the
switch (this currently defaults to the C# 2.0 language specification).
</dd><dt>
<i>ISO-1</i></dt><dd>
Restrict compiler to use only first ISO standardized features.
The usage of features such as generics, static classes, anonymous
methods will lead to error.
</dd><dt>
<i>ISO-2</i></dt><dd>
Restrict compiler to use only the second ISO standardized features.
This allows the use of generics, static classes, iterators and
anonymous methods for example.
</dd><dt>
<i>linq</i></dt><dd>
This enables the C# 3.0 support.   Only a few features of C# 3.0 have
been implemented in the Mono C# compiler, so not everything is
available. 
</dd></dl><p>
Notice that this flag only controls the language features available to
the programmer, it does not control the kind of assemblies produced.
Programs compiled with mcs will reference the 1.1 APIs, Programs
compiled with gmcs reference the 2.0 APIs.

</p></blockquote>
</dd><dt>
<i>-lib:PATHLIST</i></dt><dd>
Each path specified in the comma-separated list will direct the
compiler to look for libraries in that specified path.
</dd><dt>
<i>-L PATH</i></dt><dd>
Directs the compiler to look for libraries in the specified path.
Multiple paths can be provided by using the option multiple times.
</dd><dt>
<i>-main:CLASS</i></dt><dd>
Tells the compiler which CLASS contains the entry point. Useful when
you are compiling several classes with a Main method.
</dd><dt>
<i>-nostdlib, -nostdlib+</i></dt><dd>
Use this flag if you want to compile the core library.  This makes the
compiler load its internal types from the assembly being compiled.
</dd><dt>
<i>-noconfig, -noconfig+</i></dt><dd>
Disables the default compiler configuration to be loaded.  The
compiler by default has references to the system assemblies. 
</dd><dt>
<i>-nowarn:WARNLIST</i></dt><dd>
Makes the compiler ignore warnings specified in the comma-separated
list WARNLIST&gt;
</dd><dt>
<i>-optimize, -optimize+, -optimize-</i></dt><dd>
Controls whether to perform optimizations on the code.   -optimize and
-optimize+ will turn on optimizations, -optimize- will turn it off.
The default in mcs is to optimize+.
</dd><dt>
<i>-out:FNAME, -o FNAME</i></dt><dd>
Names the output file to be generated.
</dd><dt>
<i>--parse</i></dt><dd>
Used for benchmarking.  The compiler will only parse its input files.
</dd><dt>
<i>-pkg:package1[,packageN]</i></dt><dd>
Reference assemblies for the given packages.
<p>
The compiler will invoke pkg-config --libs on the set of packages
specified on the command line to obtain libraries and directories to
compile the code.
</p><p>
This is typically used with third party components, like this:
</p><pre>


		$ mcs -pkg:gtk-sharp demo.cs
</pre>
<blockquote>

<dl><dt>
<i>-pkg:dotnet</i></dt><dd>
This will instruct the compiler to reference the System.* libraries
available on a typical dotnet framework installation, notice that this
does not include all of the Mono libraries, only the System.* ones.  This
is a convenient shortcut for those porting code.
</dd><dt>
<i>-pkg:olive</i></dt><dd>
Use this to reference the "Olive" libraries (the 3.0 and 3.5 extended
libraries).
</dd><dt>
<i>-pkg:silver</i></dt><dd>
References the assemblies for creating Moonlight/Silverlight
applications.  This is automatically used when using the 
<i>smcs </i>
compiler, but it is here when developers want to use it with the
<i>gmcs</i>
compiler.
</dd><dt>
<i>-pkg:silverdesktop</i></dt><dd>
Use this option to create Moonlight/Silverlight applications that
target the desktop.   This option allows developers to consume the
Silverlight APIs with the full 2.0 profile API available to them,
unlike 
<i>smcs </i>
it gives full access to all the APIs that are part of Mono.  The only
downside is that applications created with silverdesktop will not run
on the browser.   Typically these applications will be launched
with the 
<i>mopen</i>
command line tool.

</dd></dl></blockquote>
</dd><dt>
<i>-resource:RESOURCE[,ID]</i></dt><dd>
Embeds to the given resource file.  The optional ID can be used to
give a different name to the resource.  If not specified, the resource
name will be the file name.
</dd><dt>
<i>-linkresource:RESOURCE[,ID]</i></dt><dd>
Links to the specified RESOURCE.  The optional ID can be used to give
a name to the linked resource.
</dd><dt>
<i>-r:ASSEMBLY1[,ASSEMBLY2], -r ASSEMBLY1[,ASSEMBLY2]</i></dt><dd>
Reference the named assemblies.  Use this to use classes from the named
assembly in your program.  The assembly will be loaded from either the
system directory where all the assemblies live, or from the path
explicitly given with the -L option.
</dd></dl><p>
You can also use a semicolon to separate the assemblies instead of a
comma. 
</p><dl><dt>
<i>-recurse:PATTERN, --recurse PATTERN</i></dt><dd>
Does recursive compilation using the specified pattern.  In Unix the
shell will perform globbing, so you might want to use it like this:
</dd></dl><p>
</p><pre>

		$ mcs -recurse:'*.cs' 
</pre>
<dl><dt>
<i>--stacktrace</i></dt><dd>
Generates a stack trace at the time the error is reported, useful for
debugging the compiler.
</dd><dt>
<i>-target:KIND, -t:KIND</i></dt><dd>
Used to specify the desired target.  The possible values are: exe
(plain executable), winexe (Windows.Forms executable), library
(component libraries) and module (partial library).
</dd><dt>
<i>--timestamp</i></dt><dd>
Another debugging flag.  Used to display the times at various points
in the compilation process.
</dd><dt>
<i>-unsafe, -unsafe+</i></dt><dd>
Enables compilation of unsafe code.
</dd><dt>
<i>-v </i></dt><dd>
Debugging. Turns on verbose yacc parsing.
</dd><dt>
<i>-v2</i></dt><dd>
Turns on C# 2.0 language features.
</dd><dt>
<i>--version</i></dt><dd>
Shows the compiler version.
</dd><dt>
<i>-warnaserror, -warnaserror+</i></dt><dd>
Treat warnings as errors.
</dd><dt>
<i>-warn:LEVEL</i></dt><dd>
Sets the warning level.  0 is the lowest warning level, and 4 is the
highest.  The default is 2.
</dd><dt>
<i>-win32res:FILE</i></dt><dd>
Specifies a Win32 resource file (.res) to be bundled into the
resulting assembly.
</dd><dt>
<i>-win32icon:FILE</i></dt><dd>
Attaches the icon specified in FILE on the output into the resulting
assembly.
</dd><dt>
<i>--</i></dt><dd>
Use this to stop option parsing, and allow option-looking parameters
to be passed on the command line.
</dd></dl><p>
</p></blockquote><h2>SPECIAL DEFINES</h2><blockquote>
The 
<b>TRACE</b>
and
<b>DEBUG</b>
defines have a special meaning to the compiler.
<p>
By default calls to methods and properties in the
System.Diagnostics.Trace class are not generated unless the TRACE
symbol is defined (either through a "#define TRACE") in your source
code, or by using the
<i>--define TRACE</i>
in the command line.
</p><p>
By default calls to methods and properties in the
System.Diagnostics.Debug class are not generated unless the DEBUG
symbol is defined (either through a "#define DEBUG") in your source
code, or by using the
<i>--define DEBUG</i>
in the command line.
</p><p>
Note that the effect of defining TRACE and DEBUG is a global setting,
even if they are only defined in a single file.
</p><p>
</p></blockquote><h2>DEBUGGING SUPPORT</h2><blockquote>
When using the "-debug" flag, MCS will generate a file with the
extension .mdb that contains the debugging information for the
generated assembly.  This file is consumed by the Mono debugger (mdb).
</blockquote><h2>ENVIRONMENT VARIABLES</h2><blockquote>
<dl><dt>
<i>MCS_COLORS</i></dt><dd>
If this variable is set, it contains a string in the form
"foreground,background" that specifies which color to use to display
errors on some terminals.  
<p>
The background is optional and defaults to your terminal current
background.   The possible colors for foreground are:
<b>black, red, brightred, green, brightgreen, yellow, brightyellow,</b>
blue, brightblue, magenta, brightmagenta, cyan, brightcyan, grey,
white and brightwhite.
</p><p>
The possible colors for background are: black, red, green, yellow,
blue, magenta, cyan, grey and white.
</p><p>
For example, you could set these variable from your shell:
</p><pre>

	export MCS_COLORS
	MCS_COLORS=errors=brightwhite,red
</pre>
<p>
You can disable the built-in color scheme by setting this variable to
"disable".
</p></dd></dl></blockquote><h2>NOTES</h2><blockquote>
During compilation the MCS compiler defines the __MonoCS__ symbol,
this can be used by pre-processor instructions to compile Mono C#
compiler specific code.   Please note that this symbol is only to test
for the compiler, and is not useful to distinguish compilation or
deployment platforms.  
</blockquote><h2>AUTHORS</h2><blockquote>
The Mono C# Compiler was written by Miguel de Icaza, Ravi Pratap,
Martin Baulig, Marek Safar and Raja Harinath.  The development was
funded by Ximian, Novell and Marek Safar.
<p>
</p></blockquote><h2>LICENSE</h2><blockquote>
The Mono Compiler Suite is released under the terms of the GNU GPL.
Please read the accompanying `COPYING' file for details.  Alternative
licensing for the compiler is available from Novell.
<p>
</p></blockquote><h2>SEE ALSO</h2><blockquote>
mdb(1), mono(1), mopen(1), mint(1), sn(1)
<p>
</p></blockquote><h2>BUGS</h2><blockquote>
To report bugs in the compiler, you must file them on our bug tracking
system, at:
http://www.mono-project.com/Bugs 
</blockquote><h2>MAILING LIST</h2><blockquote>
The Mono Mailing lists are listed at http://www.mono-project.com/Mailing_Lists
</blockquote><h2>MORE INFORMATION</h2><blockquote>
The Mono C# compiler was developed by Novell, Inc
(http://www.novell.com, http) and is based on the
ECMA C# language standard available here:
http://www.ecma.ch/ecma1/STAND/ecma-334.htm
<p>
The home page for the Mono C# compiler is at http://www.mono-project.com/CSharp_Compiler

